using Verse;

namespace RimWorld;

public class CompAbilityEffect_HemogenCost : CompAbilityEffect
{
	public new CompProperties_AbilityHemogenCost Props => (CompProperties_AbilityHemogenCost)props;

	public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
	{
		base.Apply(target, dest);
		GeneUtility.OffsetHemogen(parent.pawn, 0f - Props.hemogenCost);
	}

	public override bool GizmoDisabled(out string reason)
	{
		Gene_Hemogen gene_Hemogen = parent.pawn.genes?.GetFirstGeneOfType<Gene_Hemogen>();
		if (gene_Hemogen == null)
		{
			reason = "AbilityDisabledNoHemogenGene".Translate(parent.pawn);
			return true;
		}
		if (gene_Hemogen.Value < Props.hemogenCost)
		{
			reason = "AbilityDisabledNoHemogen".Translate(parent.pawn);
			return true;
		}
		reason = null;
		return false;
	}

	public override bool AICanTargetNow(LocalTargetInfo target)
	{
		if ((parent.pawn.genes?.GetFirstGeneOfType<Gene_Hemogen>()).Value < Props.hemogenCost)
		{
			return false;
		}
		return true;
	}
}
